from java.lang import *
from java.io import *
from org.gridlab.gat import *
from org.gridlab.gat.security import *
from org.gridlab.gat.io import *
path = r'C:\packages\jylab-0.2\lib\java\javagat-1.2'  
System.setProperty('gat.adaptor.path', path)


location = 'ftp://ftp.ntua.gr/pub/00_index.txt'
username = 'anonymous'
password = 'gdk@hpclab.ceid.upatras.gr'
context = GATContext()
pwd = PasswordSecurityContext(username, password)
context.addSecurityContext(pwd)

filestream = GAT.createFileInputStream(context,
                                       URI(location))
reader = InputStreamReader(filestream)
bufferedreader = BufferedReader(reader)
for i in range(10):
    line = bufferedreader.readLine()
    print line
filestream.close()
